package com.mohe.shanpao.utils;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.mohe.shanpao.domain.user.SysFunction;
import com.mohe.shanpao.service.user.SysFunctionService;

@Component
public class SystemInitLoader implements CommandLineRunner{
	
	private static Logger logger = LoggerFactory.getLogger(SystemInitLoader.class);
	
	@Autowired
	private SysFunctionService sysFunctionService;
	
	@Override
	public void run(String... args) throws Exception {
		
		List<SysFunction> functions = sysFunctionService.selectAll();
		
		for(SysFunction function : functions)
		{
			Constants.PERMS_MAP.put(function.getUrl(), function.getPermission());
		}
		
		logger.info("System Init Loader finish ...");
		
	}

}
